<?php echo $header; ?>
<style>.list tbody td{background:none;}</style>
<div id="content">
  <div class="breadcrumb">
    <?php foreach ($breadcrumbs as $breadcrumb) { ?>
    <?php echo $breadcrumb['separator']; ?><a href="<?php echo $breadcrumb['href']; ?>"><?php echo $breadcrumb['text']; ?></a>
    <?php } ?>
  </div>
  <div class="box">
    <div class="heading">
      <h1><img src="view/image/customer.png" alt="" /> Thống Kê Hoa Hồng Gián Tiếp</h1>
    </div>
    <div class="content">
	<div class="overview" style="width:45%;">
        <div class="dashboard-heading">Doanh Thu</div>
        <div class="dashboard-content" style="min-height:initial;padding:5px;font-weight:bold">
          <table>
            <tbody><tr>
              <td>Tổng doanh thu:</td>
              <td><?php echo $total;?></td>
            </tr>
			<tr> 
			  <td>Chưa chuyển:</td>
              <td><?php echo $total_chuyen;?></td>
            </tr>
			<tr> 
			  <td>Đã chuyển:</td>
              <td><?php echo $total_chua_chuyen;?></td>
            </tr>
          </tbody></table>
        </div>
      </div><div class="overview"  style="width:45%;float:right">
        <div class="dashboard-heading">Tìm kiếm & Thống Kê</div>
        <div class="dashboard-content" style="min-height:initial;padding:5px;font-weight:bold">
          <table class="list" style="margin-bottom:0">
          <tbody>
		   <thead>
				<tr>
				   <td class="left">Ngày bắt đầu</td> 
				   <td class="left">Ngày kết thúc</td>
					<td class="left"></td>
				</tr>
			  </thead>
            <tr class="filter">
			  
              <td><input type="text" name="filter_date_start" value="<?php echo $filter_date_start; ?>" size="40" class="date" /></td>
              <td><input type="text" name="filter_date_end" value="<?php echo $filter_date_end; ?>" size="40" class="date" /></td>
              <td align="right"><a onclick="filter();" class="button">Tìm</a></td>
			</tr> 
			<tr class="filter">
              <td class="right">Tìm Theo Mã Thành Viên</td>
              <td><input type="text" name="filter_madn" value="" size="40"/></td>
              <td align="right"></td>
			</tr>  
          </tbody>
        </table>
		
        </div>
      </div>
	  <div style="clear:both"></div>
      <form action="" method="post" enctype="multipart/form-data" id="form">
	  <div class="dashboard-heading">Thống Kê Chi Tiết</div>
		<table class="list">
		 <thead>
            <tr>
               <td class="left">Mã Nhận</td> 
			   <td class="left">Mã Phát</td>
			   <td class="left">Tiền</td>
			   <td class="left">Tên</td>
			   <td class="left">Email</td>
			   <td class="left">Ngày Tính</td>
               <td class="left">Trạng Thái</td>
               <td class="left">Ngày chuyển</td>
            </tr>
          </thead>
          <tbody>
            <?php if ($customers) { ?>
            <?php foreach ($customers as $customer) { ?>
			<?php if($customer['status_id']){?>
				<tr>
			<?php } else { ?>
				<tr style="border-left:5px solid #1900ff">
			<?php }?>
              <td class="left"><?php echo $customer['parent']; ?></td>
              <td class="left"><?php echo $customer['madn']; ?></td>
              <td class="left"><?php echo $customer['price']; ?></td>
              <td class="left"><?php echo $customer['name']; ?></td>
              <td class="left"><?php echo $customer['email']; ?></td>
              <td class="left"><?php echo $customer['date_added']; ?></td>
              <td class="left"><?php echo $customer['status']; ?></td>
              <td class="left"><?php echo $customer['date_edit']; ?></td>
            </tr>
            <?php } ?>
            <?php } else { ?>
            <tr>
              <td class="center" colspan="10"><?php echo $text_no_results; ?></td>
            </tr>
            <?php } ?>
          </tbody>
        </table>
      </form>
      <div class="pagination"><?php echo $pagination; ?></div>
    </div>
  </div>
</div>
<script type="text/javascript"><!--
function filter() {
	url = 'index.php?route=sale/hoahonggiantiep&token=<?php echo $token; ?>';
	
	var filter_date_start = $('input[name=\'filter_date_start\']').attr('value');
	
	if (filter_date_start) {
		url += '&filter_date_start=' + encodeURIComponent(filter_date_start);
	}
	var filter_date_end = $('input[name=\'filter_date_end\']').attr('value');
	
	if (filter_date_end) {
		url += '&filter_date_end=' + encodeURIComponent(filter_date_end);
	}
	
	location = url;
}


$('input[name=\'filter_madn\']').autocomplete({
	delay: 500,
	source: function(request, response) {
		$.ajax({
			url: 'index.php?route=sale/customer/autocompleteCustomer&token=<?php echo $token; ?>&filter_customer=' +  encodeURIComponent(request.term),
			dataType: 'json',
			success: function(json) {		
				response($.map(json, function(item) {
					return {
						label: item.madn,
						value: item.customer_id
					}
				}));
			}
		});
	}, 
	select: function(event, ui) {
		location.href =' index.php?route=sale/customer/update&token=<?php echo $token; ?>&filter_customer=' +  ui.item.value;
	},
	focus: function(event, ui) {
      return false;
   }
});
//--></script>
<script type="text/javascript"><!--
$(document).ready(function() {
	$('.date').datepicker({dateFormat: 'yy-mm-dd'});
});
//--></script>
<?php echo $footer; ?> 